package com.yeskery.nut.web.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeskery.nut.web.demo.domain.Wallet;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 钱包mapper
 * @author Yeskery
 * 2023/7/28
 */
public interface WalletMapper extends BaseMapper<Wallet> {
    /**
     * 扣除用户积分
     * @param userId
     * @param point
     * @return
     */
    @Update("update tbl_wallet set point = point - #{point} where user_id = #{userId} and point >= #{point}")
    int deductPoint(@Param("userId") Integer userId, @Param("point") Integer point);
}
